using ApiDemo.Api.Service;
using ApiDemo.Application.Common.Interface;
using ApiDemo.Infrastructure;
using ApiDemo.Infrastructure.Log;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
// 配置日志
builder.ConfigureLog();

builder.Services.AddSingleton<ISessionUserService,SessionUserService>();

// 这个还是需要的
builder.Services.AddHttpContextAccessor();

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

// 添加基础设施配置
builder.Services.AddInfrastructure(builder.Configuration);

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseAuthentication();
app.UseAuthorization();

app.MapControllers();

// 调用扩展方法
app.MigrateDatabase();

app.Run();
